#include "Task.h"
#include <climits>



static unsigned int GenId()
{
	static unsigned int sId = 0;
	sId = (sId + 1) % UINT_MAX;
	return sId;
}


Task::Task() :
	id_(GenId()),
	owner_(nullptr),
	priority_(0)
{
}

Task::~Task()
{
	//
}

bool Task::OnSchedule()
{
	return false;
}

void Task::OnComplete()
{
	//
}

void SimpleTask::SetCompleteFunction(const std::function<void()>& func)
{
	completeFunc_ = func;
}

void SimpleTask::OnComplete()
{
	if (completeFunc_)
	{
		completeFunc_();
	}
}

void AsynSimpleTask::SetAsynFunction(const std::function<void()>& func)
{
	asynFunc_ = func;
}

bool AsynSimpleTask::OnSchedule()
{
	if (asynFunc_)
	{
		asynFunc_();
	}
	return true;
}
